<?php
namespace Admin\Controller;
use Think\Controller;
class CustomerController extends PublicController{ 
	 public function index(){
		 $this->display();
	 }
	 //查询客户信息
	 public function get_customer_list(){
	 	$limit = I('get.limit');
	    $page = I('get.page');
	    $like = I('get.like');
	    if($like!=""){
	    	$where="a.name like '%".$like."%' or a.moblie like '%".$like."%' or a.address like '%".$like."%'";
	    }
	 	$ret['total']=M('hotcar')->count();
	 	$ret['data']=M('customer')->alias('a')
	 	//->join('left join goods_car_type as b ON a.car_id=b.id')
	 	->field('a.id,a.name,a.moblie,a.address')
	 	->where($where)
	 	->select();
	 	$ret['code']=200;
	 	$ret['msg']="查询成功";
	 	ret($ret);
	 }
	 //客户详情展示
	 public function customer(){
	 	$id=I('post.id');
	 	$shopid=M('customer')->field('car_id,shop_id')->where(['id'=>$id])->find();
	 	$shop_id=json_decode($shopid['shop_id'],true);
	 	foreach ($shop_id as $key => $value) {
	 		$shopdetails[$key]=M('shop')->alias('a')
	 		//->join('__GOODS_CAR_TYPE__ as b on a.car_id=b.id')
	 		->field('a.shop_company,a.shop_address,a.shop_phone')
	 		->find();
	 	}
	 	foreach ($shopdetails as $ke => $val) {
	 		$shopdetails[$ke]['carname']=M('goods_car_type')->where(['id'=>$shopid['car_id']])->getField('car_name');
	 		$shopdetails[$ke]['car_pirce']=M('goods_car_type')->where(['id'=>$shopid['car_id']])->getField('car_pirce');
	 	}
	 	 //print_r($shopdetails);
	 	ret($shopdetails);
	 }
}
